package com.linsen.core.cloud.config;

import com.linsen.core.cloud.filter.TenantContextHolderFilter;
import com.linsen.core.cloud.filter.TraceFilter;
import com.linsen.core.cloud.props.LinsenCloudProperties;
import com.linsen.core.common.annotation.AutoConfiguration;
import com.linsen.core.common.factory.YamlPropertySourceFactory;
import com.linsen.core.redis.util.RedisSecurityUtil;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;

/**
 * @author zhaoyong
 * @date 2023/3/11
 */
@AutoConfiguration
@EnableConfigurationProperties({LinsenCloudProperties.class})
@PropertySource(factory = YamlPropertySourceFactory.class, value = "classpath:linsen-cloud.yml")
public class LinsenCloudAutoConfiguration {
    @Bean
    public TraceFilter traceFilter() {
        return new TraceFilter();
    }

    @Bean
    public TenantContextHolderFilter tenantContextHolderFilter(RedisSecurityUtil redisSecurityUtil) {
        return new TenantContextHolderFilter(redisSecurityUtil);
    }
}
